#!/bin/bash

yum -y install zip unzip;
yum -y install gcc;
yum -y install gcc-c++;
yum -y install zlib-devel;
yum -y install patch;
yum -y install pcre-devel;
yum -y install openssl openssl-devel;
yum -y install libcurl-dev;
yum -y install libgd2-dev;
yum -y install libpcre-dev;
yum -y install gd-devel;
yum -y install libcurl-dev libcurl-devel;

rm -rf /usr/local/packages;
cd /usr/local;
mkdir packages;
cd packages;
wget http://nginx.org/download/nginx-1.18.0.tar.gz;
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/nginx_conf.zip;
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/nginx_upstream_check_module-master.zip;
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/ngx_image_thumb-master.zip
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/ngx_dynamic_upstream-master.zip
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/pcre-8.38.zip
wget https://gitee.com/shiqiyue/StudyDoc/raw/master/shell_script/nginx/nginx

tar -zxvf nginx-1.18.0.tar.gz;
unzip nginx_conf.zip
unzip nginx_upstream_check_module-master.zip;
unzip ngx_image_thumb-master.zip;
unzip ngx_dynamic_upstream-master.zip;
unzip pcre-8.38.zip;
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_ssl_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-openssl-opt="enable-tlsext"  \
--add-module=/usr/local/packages/ngx_dynamic_upstream-master/
make
make install
rm -rf /usr/local/nginx/conf
cp -rf /usr/local/packages/conf /usr/local/nginx
cp /usr/local/packages/nginx /etc/init.d
chmod a+x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
